✨ BCA JUL24 Batch ✨

Join Our WhatsApp Group

Anukasif Pic

3.3 - Command Line Arguments - MCQs

Interactive MCQs Quiz

Test your knowledge with these questions

1. What does argc represent in a C program that uses command-line arguments?

2. What is stored in argv[0] when a C program is executed with command-line arguments?

3. How would you compile and run a C program that uses command-line arguments?

4. If a program is executed as ./program arg1 arg2 arg3, what will be the value of argc?

5. In the command-line argument example provided, what does the atoi function do?

6. Which of the following commands is used to create a new directory in the command line?

7. In the context of command-line arguments, which of the following is correct for char *argv[]?

8. What will be the output of the following program if executed as ./program 10 20?

                #include <stdio.h>
                #include <stdlib.h>
                int main(int argc, char *argv[]) {
                    int num1 = atoi(argv[1]);
                    int num2 = atoi(argv[2]);
                    int sum = num1 + num2;
                    printf("Sum: %d\n", sum);
                    return 0;
                }
                

9. Which of the following commands is used to clear the terminal screen?

10. In a program using command-line arguments, what does the first argument (argv[0]) always contain?